package vsion.demo.service.safty.impl;

import vsion.demo.model.InfoStandard;
import vsion.demo.dao.safty.InfoStandardDao;
import vsion.demo.service.safty.InfoStandardService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 产品规格表(InfoStandard)表服务实现类
 *
 * @author makejava
 * @since 2019-09-27 11:33:03
 */
@Service("infoStandardService")
public class InfoStandardServiceImpl implements InfoStandardService {
    @Resource
    private InfoStandardDao infoStandardDao;

    /**
     * 通过ID查询单条数据
     *
     * @param standardId 主键
     * @return 实例对象
     */
    @Override
    public InfoStandard queryById(Integer standardId) {
        return this.infoStandardDao.queryById(standardId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<InfoStandard> queryAllByLimit(int offset, int limit) {
        return this.infoStandardDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param infoStandard 实例对象
     * @return 实例对象
     */
    @Override
    public InfoStandard insert(InfoStandard infoStandard) {
        this.infoStandardDao.insert(infoStandard);
        return infoStandard;
    }

    /**
     * 修改数据
     *
     * @param infoStandard 实例对象
     * @return 实例对象
     */
    @Override
    public InfoStandard update(InfoStandard infoStandard) {
        this.infoStandardDao.update(infoStandard);
        return this.queryById(infoStandard.getStandardId());
    }

    /**
     * 通过主键删除数据
     *
     * @param standardId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer standardId) {
        return this.infoStandardDao.deleteById(standardId) > 0;
    }
}